package com.bluedot.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import com.bluedot.dao.UserDao;
import com.bluedot.domain.User;



public class UserDaoImpl extends HibernateDaoSupport<User, Long> implements
		UserDao {

	public UserDaoImpl() {
		this.entityClass = User.class;
	}

	@Override
	public List<User> findUserByName(String userName) {
		Session session = null;
		List<User> list = null;
		try {
			session = this.getSession();
			session.beginTransaction().begin();
			Query query = session
					.createQuery("from User u,Role r where u.roleId=r.roleId and u.userName=?");
			query.setParameter(0, userName);
			list = query.list();
			session.getTransaction().commit();

		} catch (RuntimeException e) {
			e.printStackTrace();
		}
		return list;

	}


}
